// @Title mailSend.go
// @Description:
// @Author 姓名编写
// @Date 2024/3/5
// @Update 姓名编写 2024/3/5

/**************************************************
*Copyright(C).2016-2024,瀚辰光翼⽣物科技有限公司
*文件名：mailSend.go
*内容简述：*
*文件历史：
author 姓名编写 创建 2024/3/5
**************************************************/
package send

import (
	"cec-server/app/model"
	"context"
	"gopkg.in/gomail.v2"
	"log"
)

type MailSend struct {
}

func NewMailSend() *MailSend {
	return &MailSend{}
}

func (m MailSend) DoHandler(ctx context.Context, taskInfo model.TaskInfo) {

	from := "709275139@qq.com"
	password := "eeuqumstptpibbhh"
	to := "1113773197@qq.com"
	subject := "邮件主题"
	body := "邮件正文"

	message := gomail.NewMessage()
	message.SetHeader("From", from)
	message.SetHeader("To", to)
	message.SetHeader("Subject", subject)
	message.SetBody("text/plain", body)

	d := gomail.NewDialer("smtp.qq.com", 587, from, password)

	err := d.DialAndSend(message)
	if err != nil {
		log.Print(err)
	}

	log.Println("邮件发送成功！")

	//// 邮件相关配置
	//from := "709275139@qq.com"
	//password := "sjkdsy520"
	//to := "recipient@example.com"
	//subject := "Test Email"
	//body := "This is the body of the email."
	//
	//// SMTP 服务器地址和端口
	//smtpHost := "smtp.qq.com"
	//smtpPort := "25"
	//
	//// 构建邮件内容
	//message := []byte("To: " + to + "\r\n" +
	//	"Subject: " + subject + "\r\n" +
	//	"\r\n" +
	//	body + "\r\n")
	//
	//// 连接到 SMTP 服务器
	//auth := smtp.PlainAuth("", from, password, smtpHost)
	//err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{to}, message)
	//if err != nil {
	//	log.Fatal(err)
	//}
	//
	//log.Println("Email sent successfully!")

}

func (m MailSend) SendMessage(param model.MessageParam) {
}
